<template>
  <div class="nav">
    <swiper :options="swiperOption">
      <swiper-slide v-for="(page, index) in pages" :key="index">
        <div class="nav-icon-box" v-for="item in page" :key="item.id">
          <img class="nav-icon" :src="item.imgUrl" alt="" />
          <p>{{item.desc}}</p>
        </div>
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
      <!-- <div class="swiper-button-prev" slot="button-prev"></div>
      <div class="swiper-button-next" slot="button-next"></div>
      <div class="swiper-scrollbar"   slot="scrollbar"></div> -->
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeNavIcon',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
      }
    }
  },
  computed: {
    pages: function () {
      const pages = []
      this.list.forEach(function (item, index) {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang = "stylus" scoped>
.nav >>> .swiper-wrapper
 height:3.2rem
.nav
  width:100%;
  height:3.2rem;
  .nav-icon-box
    box-sizing: border-box;
    padding-top: 0.13rem;
    position: relative;
    height: 1.6rem;
    width: 25%;
    float: left;
    text-align: center;
    color: #757575;
    font-size:0.2rem;
    p
      position relative;
      top 0.1rem
    .nav-icon
      display: block;
      margin: 0 auto;
      width: 1rem;
      height: 1rem;
</style>
